import {CreatePatientForm, EditPatientForm, PatientQueryParams, PatientType} from "@/api/patient/types";
import http from "@/utils/http";
import {ListResponse} from "@/types";

/**
 * 患者列表
 * @param params
 */
export const patientListApi = async (params: PatientQueryParams)=>{
    const res = await http.get<ListResponse<PatientType>>("/v1/patient", params)
    return res.data.data
}

/**
 * 创建患者
 * @param params
 */
export const createPatientApi = async (params: CreatePatientForm)=>{
    const res = await http.post<ListResponse<PatientType>>("/v1/patient", params)
    return res.data.data
}

/**
 * 修改患者信息
 * @param params
 */
export const editPatientApi = async (params: EditPatientForm)=>{
    const res = await http.patch("/v1/patient", params)
    return res.data
}

/**
 * 删除患者信息
 * @param id
 */
export const deletePatientApi = async (id: number)=>{
    const res = await http.delete(`/v1/patient/${id}`, {})
    return res.data
}
/**
 * 患者详情
 * @param id
 */
export const patientDetailApi = async (id: number)=>{
    const res = await http.get<PatientType>(`/v1/patient/${id}`, {})
    return res.data
}